/*
*** (C) 2008-2009 UCMai.com ***

Subj: 个人管理-修改资料
Auth: zhouyt
Date: 2008-07-31
*/

c.pgsubject = '用户';

var UserInfo = function(){

	//修改记录时表单需要绑定的当前值字段
	this.formReader = [
		{name:'DepartmentID'},
		{name:'UserName'},
		{name:'sex'},
		{name:'Tel'},
		{name:'MobileTel'},
		{name:'QQ'},
		{name:'MailAddr'},
		{name:'Remark'}
	];

	//表单项
	this.formItems = [
		{
			fieldLabel:'部门',
			name:'DepartmentID',
			id:'se_o_departmentid',
			allowBlank:false,
			anchor:'85%',
			readOnly: true
		},
		{
			fieldLabel: '登录名',
			id:'se_o_username',
			name: 'UserName',
			anchor:'85%',
			allowBlank:false,
			readOnly: true
		},
		{
			xtype:'combo',
			store:genderStore(),
			displayField:'GenderT',
			valueField:'GenderTID',
			fieldLabel:'性别',
			name:'sex',
			hiddenName:'sex',
			id:'se_o_sex',
			mode:'local',
			triggerAction: 'all',
			blankText:'请选择性别',
			emptyText:'选择性别',
			allowBlank:false,
			anchor:'85%',
			editable: false
		},
		{
			fieldLabel: '电话号码',
			name: 'Tel',
			id:'se_o_tel',
			anchor:'85%'
		},
		{
			fieldLabel: '手机号码',
			name: 'MobileTel',
			id:'se_o_mobiletel',
			anchor:'85%'
		},
		{
			xtype:'numberfield',
			fieldLabel: 'QQ号码',
			name: 'QQ',
			id:'se_o_qq',
			anchor:'85%'
		},
		{
			fieldLabel: '电子邮箱',
			name: 'MailAddr',
			id:'se_o_mailaddr',
			vtype:'email',
			anchor:'85%'
		},
		{
			xtype:'textarea',
			fieldLabel: '描述',
			name: 'Remark',
			id:'se_o_remark',
			width:180,
			height:50
		},
		{xtype:'hidden',name: 'li',id:'se_o_li',value:'1'},
		{xtype:'hidden',name: 'ln',id:'se_o_ln'}
	];

	this.showWindow = function(str){
		zyt.Permit();
		this.form = new Ext.FormPanel({
				labelAlign:'left',
				bodyStyle:'padding:5px',
				frame:true,
				labelWidth:60,
				reader : new Ext.data.JsonReader({
					root : 'record',
					success: '@success'
				},this.formReader),
				items:[{
					layout:'form',
					defaultType:'textfield',
					border:false,
					labelSeparator:'：',
					items:this.formItems
				}]
		});
		this.form.getForm().reset();
		//if (!this.window){
		this.window = new Ext.Window({
			xtype:'window',
			title:'修改资料',
			iconCls: 'modify',
			buttonAlign : 'right',
			closable:true,
			resizable: false,
			layout:'fit',
			modal: 'true',
			width:320,
			height:360,
			closeAction:'hide',
			plain: true,
			items:[this.form],
			keys: {
				key: Ext.EventObject.ENTER,
				fn: save.createDelegate(this,[str])
			},
			buttons: [{
				id: 'btnSave',
				text: c.bsave,
				handler: save.createDelegate(this,[str]),
				disabled: false
			},{
				text: c.bcancel,
				handler: function(){
					this.window.hide();
				}.createDelegate(this)
			}]
		});
		this.window.on('hide',function(){
			this.form.destroy();
		}.createDelegate(this));
		//}

		this.window.show();
		//this.form.findById('se_o_username').focus(false,true);

		this.form.getForm().load({
			url:_C_User_PersonInfo,
			method:'GET',
			params:'a=7',
			waitMsg:'正在获取数据，请稍候...'
		});
	};

	var save = function(str){
		if (!this.form.getForm().isValid()){
			return;
		}

		//this.form.findById('se_o_cmdid').setValue(6);
		showLoading(c.g(c.e.save),c.loading);
		zyt.ajax(_C_User_PersonSave,this.form.getForm().getValues(), function(){
			hideLoading();
			this.window.hide();
			var act = c.modify;
			Ext.HandleTip.msg(c.opres,c.item +  act +c.ok);
		}.createDelegate(this));
	};

	this.showWindow();
};